package com.gadgets.framework.statusmach.init;

import com.gadgets.framework.start.AbsCacheInitLoaderProcess;
import com.gadgets.framework.statusmach.pojo.StatusMachine;
import com.gadgets.framework.statusmach.repository.IStatusMachineRepository;
import com.gadgets.framework.statusmach.util.StatusUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020-09-27
 *
 */
@Component
public class StatusMachineInitLoadProcess extends AbsCacheInitLoaderProcess {

    public StatusMachineInitLoadProcess() {
        super("4");
    }

    @Autowired
    private IStatusMachineRepository statusMachineRepository;

    /**
     * 初始化执行方法
     */
    @Override
    public void initLoad() {
        List<StatusMachine> list = statusMachineRepository.queryStatusMachine(null);
        for (StatusMachine machine : list) {
            StatusUtil.addStatusMachine(machine);
        }
        StatusUtil.refreshStatusCache();
    }

}
